package com.crm.global.handler;

import com.crm.global.exception.CrmException;
import com.crm.global.result.Message;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class ControllerExceptionHandler {
    @ExceptionHandler(CrmException.class)
    public ResponseEntity handler(CrmException e) {

        return ResponseEntity.status(e.getExceptionEnum().getCode())
                .body(new Message<>(e.getExceptionEnum()));
    }

}
